import { copy } from "./common";

export function analysisResponse(request, state, key) {
  request.getContent((value) => {
    if (typeof value === "string") {
      value = JSON.parse(value);
    }
    state[key] = value;
  });
}

export function analysisResponseWithCb(request, cb) {
  request.getContent((value) => {
    cb(value);
  });
}

export function copyResponseAsJson(request) {
  analysisResponseWithCb(request, (str) => { copy(str); });
}